<template>
	<div>
		<Row style="margin-top: 20px;margin-bottom: 20px;margin-left: 20px;">
	        <Col span="6">
	        	<span>科目：</span>
				<Select v-model="subjectselect" style="width:150px" @on-change="subjectselectChange">
			        <Option v-for="item in subjectlist" :value="item.value" :key="item.value">{{ item.label }}</Option>
			    </Select>
	        </Col>
	        <Col span="6">
	        	<span>教师：</span>
				<Select v-model="teacherSelect" style="width:150px" @on-change="teacherSelectChange">
			        <Option v-for="item in teacherList" :value="item.value" :key="item.value">{{ item.label }}</Option>
			    </Select>
	        </Col>
	    </Row>
	    <Row style="text-align: left;margin-top: 41px;">
			<Col span="12" style="text-align: left;">
    			<span style="border-left: 5px solid #517EDB;font-size: 16px;"></span>
    			<span style="font-size: 16px;font-weight: 800;margin-left: 41px;">历史列表</span>
			</Col>
			<Col span="11" style="text-align: right;">
	        	<Input v-model="searchInfo" icon="ios-search" @on-click="searchTeacher" @on-enter="searchTeacher" placeholder="教师姓名/评价名称" style="width: 200px;cursor: pointer;"></Input>
	       </Col>
		</Row >
		<div style="padding: 10px 20px 20px 20px;">
	    	<div style="position: relative;">
			    <Table  border ref="selection" :columns="columns4" :data="data1" @on-selection-change="tableteacherselect"></Table>
		        <!--<Spin size="large" fix v-if="tableshow"></Spin>-->
	        </div>
	        <Page style="text-align: center;margin-top:15px;" :current="current" :total="recordCount" @on-change="pageChange"/>
	    </div>
	</div>
</template>

<script>
	import { getsessionstorage } from '@/components/js/Localstorage'
	import api from "@/components/js/Apidomain.js"
	export default{
		data(){
			return{
				subjectselect:"",
				teacherSelect:"",
				
				subjectlist:[],
				teacherList:[],
				
				searchInfo:"",
				//分页
		        recordCount:0,				//总条数
				current:1,					//页码
				
				columns4: [
//                  {type: 'selection',width: 60,align: 'center'},
                    {title: '工号',key: 'teacherNo',align: 'center',},
                    {title: '姓名',key: 'teacherName',align: 'center',},
                    {title: '学部',key: 'division',align: 'center',},
                    {title: '科目',key: 'subjectName',align: 'center',},
                    {title: '评价名称',key: 'performName',align: 'center',},
                    {title: '时间',key: 'time',align: 'center',},
                    {title: '评价得分',key: 'teacherResult',align: 'center',},
                    {title: '评价平均分',key: 'subjectResult',align: 'center',},
                    {title: '均差值',key: 'dValue',align: 'center',},                    
                ],
                data1: [
//                  {id:"4444",teacherNo:"122672013040",teacherName: '张三',subject: '语文',jobTitle: '初一'},
                ],
			}
		},
		created(){
			this.getSubject()
		},
		methods:{
			subjectselectChange:function(){
				this.getTeacherList()
			},
			teacherSelectChange:function(){
				this.current = 1;
				this.teacherHistoryInfo()
			},
			getSubject:function(){
           		var self = this;
           		let roleId = getsessionstorage("roleid");
            	let url = api.apidomain+'/tqes/web/quaTeacherResults/getSubject';
            	this.$http.post(url,{"roleId":roleId}).then(function(response) {
					if(response.data.success == true){
//						////console.log(response.data.data)
						self.subjectlist = response.data.data
						if(self.subjectlist.length != 0){
							self.subjectselect = self.subjectlist[0].value;
							self.getTeacherList()
						}
		            }else if(response.data.success == false){
		            		self.$Message.error({
								content: response.data.msg,
								duration: 10,
								closable: true
							});	
		            	}
					})
					.catch(function(error) {
						self.$Message.error({
							content: '系统发生错误：错误码00083',
							duration: 10,
							closable: true
						});
					});
			},
			getTeacherList:function(){
				var self = this;
           		let roleId = getsessionstorage("roleid");
            	let url = api.apidomain+'/tqes/web/quaTeacherResults/getTeacherList';
            	this.$http.post(url,{"roleId":roleId,"type":"Middle","subjectId":this.subjectselect}).then(function(response) {
					if(response.data.success == true){
//						////console.log(response.data.data)
						self.teacherList = response.data.data
						if(self.teacherList.length != 0){
							self.teacherSelect = self.teacherList[0].value;
							self.current = 1;
							self.teacherHistoryInfo()
						}
		            }else if(response.data.success == false){
		            		self.$Message.error({
								content: response.data.msg,
								duration: 10,
								closable: true
							});
		            	}
					})
					.catch(function(error) {
						self.$Message.error({
							content: '系统发生错误：错误码00084',
							duration: 10,
							closable: true
						});
					});
			},
			tableteacherselect:function(selection){
           		this.selections = selection
           	},
           	pageChange:function(value){
        		this.current = value;
        		this.teacherHistoryInfo()
        	},
        	//获取列表信息
        	teacherHistoryInfo:function(){
        		let roleId = getsessionstorage("roleid");
        		var senddata = { 
           			"current":this.current,
					"pageSize":"10",
					"type": "Middle",						//---学部
           			"subjectId":this.subjectselect,			//---学科id
					"teacherId":this.teacherSelect,			//--老师id
					"nameByPerformAndTeacher":"",
					"roleId":roleId
				}
        		if(this.searchInfo != ""){
        			senddata.nameByPerformAndTeacher = this.searchInfo;
        		}
           		var self = this;
            	let url = api.apidomain+'/tqes/web/quaTeacherResults/TeacherHistoryInfo';
            	this.$http.post(url,senddata).then(function(response) {
					if(response.data.success == true){
						
//						console.log(response.data.data)
						self.data1 = response.data.data.items
						self.recordCount = response.data.data.recordCount
//						self.tableshow = false;
		            }else if(response.data.success == false){
		            		self.$Message.error({
								content: response.data.msg,
								duration: 10,
								closable: true
							});
//		            		self.tableshow = false;
		            	}
					})
					.catch(function(error) {
						self.$Message.error({
							content: '系统发生错误：错误码00085',
							duration: 10,
							closable: true
						});
//						self.tableshow = false;
					});
        	},
        	
			searchTeacher:function(){
				let roleId = getsessionstorage("roleid");
				var senddata = { 
           			"current":this.current,
					"pageSize":"10",
					"type": "Middle",						//---学部
           			"subjectId":this.subjectselect,			//---学科id
					"teacherId":this.teacherSelect,			//--老师id
					"nameByPerformAndTeacher":this.searchInfo,
					"roleId":roleId
				}
           		var self = this;
            	let url = api.apidomain+'/tqes/web/quaTeacherResults/TeacherHistoryInfo';
            	this.$http.post(url,senddata).then(function(response) {
					if(response.data.success == true){
						
//						console.log(response.data.data)
						self.data1 = response.data.data.items
						self.recordCount = response.data.data.recordCount
//						self.tableshow = false;
		            }else if(response.data.success == false){
		            		self.$Message.error({
								content: response.data.msg,
								duration: 10,
								closable: true
							});
//		            		self.tableshow = false;
		            	}
					})
					.catch(function(error) {
						self.$Message.error({
							content: '系统发生错误：错误码00086',
							duration: 10,
							closable: true
						});
//						self.tableshow = false;
					});
			},
		},
		watch:{
			searchInfo:function(){
				this.searchTeacher();
			}
		}
	}
</script>

<style>
</style>